﻿#! /bin/bash

# 开启ip转发
firewall-cmd --add-masquerade --permanent
# 防火墙刷新，使防火墙设置立即生效
firewall-cmd --reload

# 查看ip转发是否开启
firewall-cmd --query-masquerade

yum update

# 卸载老版本docker
yum remove docker \
                      docker-client \
                      docker-client-latest \
                      docker-common \
                      docker-latest \
                      docker-latest-logrotate \
                      docker-logrotate \
                      docker-engine

# 安装docker 基础包
yum install -y yum-utils \
      device-mapper-persistent-data \
      lvm2

# 设置稳定仓库
yum-config-manager \
        --add-repo \
        https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

# 安装Docker Engine - Community
yum install -y docker-ce docker-ce-cli containerd.io --nobest

# 启动及设置为开机自启动
sudo systemctl start docker
# 设置docker开机自启动
systemctl enable docker

# 设置docker仓库国内镜像
mkdir -p /etc/docker
curl -o /etc/docker/daemon.json "https://gitee.com/wangronghua/pubfile/raw/master/_docker_daemon.json"
sudo systemctl daemon-reload
sudo systemctl restart docker